home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Graphics
/
Utility
/
ARTAbrot 1.1
/
About_ARTAbrot.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
7KB
|
186 lines
/* About_ARTAbrot */
/* File name: About_ARTAbrot */
/* Function: Handle a modeless dialog */
/* This dialog operates like a window, it is not modal. */
/* Opened by: */
/* Closed by: */
/* Purpose:
History: 8/18/93 Original by George Warner
*/
#include "ComUtil_ARTAbrot.h" /* Common */
#include "AB_Alert.h" /* Alert */
#include "About_ARTAbrot.h" /* This modeless dialog */
#pragma segment About_ARTAbrot
static Boolean ExitDialog; /* Flag to exit dialog */
/* ======================================================= */
/* ======================================================= */
/* Routine: Init_About_ARTAbrot */
/* Purpose: This procedures purpose is to set the window pointer to nil, */
/* this is used to tell the other routines */
void Init_About_ARTAbrot()
{
WPtr_About_ARTAbrot = NIL; /* Initialize to say that the dialog is not yet active */
}
/* ======================================================= */
/* Routine: Moved_About_ARTAbrot */
/* Purpose: We were moved, possibly to another screen and screen depth */
void Moved_About_ARTAbrot(WindowPtr theWindow)/* Moved this window */
{
WindowPtr SavePort; /* Place to save the last port */
if (WPtr_About_ARTAbrot == theWindow) { /* Only do if the window is us */
GetPort(&SavePort); /* Save the current port */
SetPort(theWindow); /* Set the port to my window */
SetPort(SavePort); /* Restore the old port */
}
}
/* ======================================================= */
/* Routine: Update_About_ARTAbrot */
/* Purpose: This procedures purpose is to refresh this window, update it, */
/* when we are uncovered by another window. */
void Update_About_ARTAbrot(WindowPtr theWindow)
{
GrafPtr SavedPort; /* Save the current port so we can restore to it */
Rect rTempRect; /* Temporary rectangle variable */
RGBColor Saved_ForeColor; /* Place to save colors */
RGBColor Saved_BackColor; /* Place to save colors */
RGBColor DrawingColor; /* Place to make colors */
/* Only do if we are the window to update */
if ((WPtr_About_ARTAbrot != nil) && (theWindow == WPtr_About_ARTAbrot)) {
GetPort(&SavedPort); /* Get the current port */
SetPort(theWindow); /* Point to our port for drawing in our window */
GetForeColor(&Saved_ForeColor); /* Save the fore color */
GetBackColor(&Saved_BackColor); /* Save the back color */
RGBForeColor(&Black_ForeColor); /* Set the fore color to Black */
RGBBackColor(&White_BackColor); /* Set the back color to White */
DrawingColor.red = 0x0000; DrawingColor.green = 0x0000; DrawingColor.blue = 0xEEEE;/* Set the color */
RGBForeColor(&DrawingColor); /* Set the fore color */
/* Draw a string of text, Static Text */
SetRect(&rTempRect, 37,94,199,159);
GetIndString(sTemp,Res_Dlg_Static_Text5,1); /* Get the string */
TextBox(&sTemp[1], sTemp[0], &rTempRect,teJustLeft);
RGBForeColor(&Black_ForeColor); /* Set the fore color to Black */
TextSize(12);
TextFont(systemFont); /* Select the Font that we want */
TextFace(0); /* Select the style that we want */
RGBForeColor(&Saved_ForeColor); /* Restore the fore color */
RGBBackColor(&Saved_BackColor); /* Restore the back color */
DrawDialog(theWindow); /* Draw the rest of the controls */
SetPort(SavedPort); /* Restore the port that we saved at the start */
}
}
/* ======================================================= */
/* Routine: Open_About_ARTAbrot */
/* Purpose: This procedures purpose is to open this window and set all */
/* of the initial conditions, such as default edit text. */
void Open_About_ARTAbrot()
{
if (WPtr_About_ARTAbrot == NIL) {
WPtr_About_ARTAbrot = GetNewDialog(Res_MD_About_ARTAbrot, NIL, (WindowPtr)-1 );/* Bring in the dialog resource */
SetPort(WPtr_About_ARTAbrot); /* Prepare to add conditional text */
Doing_MovableModal = true; /* We are now in the movable modal mode */
ShowWindow(WPtr_About_ARTAbrot); /* Open a dialog box */
SelectWindow(WPtr_About_ARTAbrot); /* Lets see it */
}
else
SelectWindow(WPtr_About_ARTAbrot); /* Lets see it */
}
/* ======================================================= */
/* Routine: Close_About_ARTAbrot */
/* Purpose: This procedures purpose is to close this window and clear */
/* the window pointer variable */
void Close_About_ARTAbrot(WindowPtr theWindow)
{
/* Only close if it is us and we were open */
if ((WPtr_About_ARTAbrot != NIL) && (theWindow == WPtr_About_ARTAbrot)) {
Doing_MovableModal = false; /* We are now out of the movable modal mode */
DisposDialog(theWindow); /* Close on the screen and Flush the dialog out of memory */
WPtr_About_ARTAbrot = nil; /* Make sure our other routines know that we are closed */
}
}
/* ======================================================= */
/* Routine: Do_About_ARTAbrot */
/* Purpose: This procedures purpose is to handle all actions, such as buttons being pressed. */
/* This is the real meat of this unit and is where the code is for acting upon the users actions. */
void Do_About_ARTAbrot(EventRecord *theEvent,WindowPtr theWindow,short itemHit)
{
Point myPt; /* For the local mouse position */
Boolean ExitDialog; /* Flag to close this dialog */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
Rect tempRect; /* Temporary rectangle */
ControlHandle CItem; /* Control handle */
ExitDialog = false; /* Do not close the dialog yet */
if ((theEvent->what == mouseDown) && (WPtr_About_ARTAbrot != nil)) {
SetPort(WPtr_About_ARTAbrot); /* Set the port to our dialog */
myPt = theEvent->where; /* Get the position where the mouse was pressed */
GlobalToLocal(&myPt); /* Change from global to local location */
}
if ((WPtr_About_ARTAbrot != nil) && (WPtr_About_ARTAbrot == theWindow)) {
if (theEvent->what == keyDown) {
itemHit = 0; /* Default to no item hit */
}
if ((WPtr_About_ARTAbrot != NIL) && (WPtr_About_ARTAbrot == theWindow)) {
myPt = theEvent->where; /* Get the position where the mouse was pressed */
GlobalToLocal(&myPt); /* Change from global to local location */
GetDItem(theWindow, itemHit,&DType,&DItem,&tempRect);/* Get which item was pressed */
CItem = (ControlHandle)DItem; /* Change the pointer for getting to the control */
/* Handle it real time */
if (itemHit ==Res_Dlg_OK2) { /* Handle the Button being pressed */
Add_UserEvent(UserEvent_Close_Window,Res_MD_About_ARTAbrot,0,0,nil);/* Open a modeless dialog */
Play_The_Sound(Snd_Bart__Cooool); /* Play my sound */
}
}
}
if (ExitDialog) { /* Do the close of the dialog */
Close_About_ARTAbrot(WPtr_About_ARTAbrot);
WPtr_About_ARTAbrot = nil; /* Clear it for future checks */
}
}